<%-- 
    Document   : content_addresource
    Created on : Jan 7, 2012, 7:41:42 AM
    Author     : Ngoc Linh
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<div id="content-col">
    <h2 class="bid_header_title" id="add_new_pro_header">Thêm tài nguyên cho sản phẩm</h2>
    <div id="add_resource">
        <fieldset>
            <legend>Khu vực upload ảnh</legend>
            <div id="upload_container" class="fl">
                <form action='uploadFile.do' name='frmUpload' method='post' enctype='multipart/form-data' onsubmit="return checkImage()">
                    <div id='fileul'>
                        <input type='file' id='myupload' name='file_1' onchange='addFile();'/>                    
                    </div>
                    <p style="margin: 10px 10px 15px 0px;">
                        <input type="hidden" id="numFile"  value="1" />
                        <input type='submit' value='Tải lên và lưu lại' class="btn_cm_common btn_option"/>
                    </p>
                </form>
            </div> 
            <div class="fr note_upload">
                Bạn được upload tối đa <b>5</b> file ảnh (png, jpg, jpeg, gif). <br/> Kích thước tối đa mỗi file là <b>1MB</b> !
            </div>
        </fieldset>
        <c:if test="${not empty sessionScope.upload}">
            <form action="addresource.do" method="post">
                <fieldset>
                    <c:if test="${not empty requestScope.message}">
                        <p class="message">
                            ${requestScope.message}
                        </p>
                    </c:if>
                    <c:if test="${not empty requestScope.messageError}">
                    <p class="message">
                        ${requestScope.messageError}
                    </p>
                    </c:if>
                    <legend>Hình ảnh đã upload <strong>(${sessionScope.upload.size()})</strong></legend>
                    <div id='listImage'>                
                        <c:forEach items="${sessionScope.upload}" var="item">
                            <div class="image_container fl">
                                <a href='../images/data/product/${item}' class='imageupload'>
                                    <img src='../images/data/product/${item}' width='90' height='80' />
                                </a> <br />
                                <input type="radio" name="main_img" value="${item}" id="${item}" checked="checked" />
                                <label for="${item}">Ảnh chính</label>
                            </div>                        
                        </c:forEach>   
                    </div>
                </fieldset>
                <p>
                    <input type="submit" value="Lưu hình ảnh" name="save_image" class="btn_cm_common btn_option" />
                    <input type="button" value="Hủy bỏ" onclick="document.location.href='home.do';" class="btn_cm_common btn_option" />
                </p>    
            </form>                            
        </c:if>   
        <c:if test="${empty sessionScope.upload}">
            <p class="noHiddenMessage">Chưa có hình ảnh nào được upload !</p>
            <c:if test="${not empty requestScope.messageError}">
                <p class="noHiddenMessage">
                    ${requestScope.messageError}
                </p>
            </c:if>
        </c:if>        
    </div>
</div>
    